package bean;


import java.io.Serializable;

import javax.faces.bean.ManagedBean;

import metier.AmiBusiness;

@ManagedBean
public class AmiBean implements Serializable {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int id_amitie;
	private int id_eleve_courant;
	private int id_eleve_ajout;
	private AmiBusiness amiBusinessCourante;

	public AmiBean(){

		super();
		amiBusinessCourante = new AmiBusiness();

	}

	public int getId_amitie() {
		return id_amitie;
	}

	public void setId_amitie(int id_amitie) {
		this.id_amitie = id_amitie;
	}

	public int getId_eleve_courant() {
		return id_eleve_courant;
	}

	public void setId_eleve_courant(int id_eleve_courant) {
		this.id_eleve_courant = id_eleve_courant;
	}

	public int getId_eleve_ajout() {
		return id_eleve_ajout;
	}

	public void setId_eleve_ajout(int id_eleve_ajout) {
		this.id_eleve_ajout = id_eleve_ajout;
	}

	public AmiBusiness getAmiBusinessCourante() {
		return amiBusinessCourante;
	}

	public void setAmiBusinessCourante(AmiBusiness amiBusinessCourante) {
		this.amiBusinessCourante = amiBusinessCourante;
	}

	
	public String save(){
		
		/* On cr�� l'autre amiBean afin que les ajouts se fassent dans les deux sens */
		AmiBean ami = new AmiBean();
		
		ami.setId_eleve_ajout(this.id_eleve_courant);
		ami.setId_eleve_courant(this.id_eleve_ajout);
		
		amiBusinessCourante.save(ami);
		amiBusinessCourante.save(this);
		
		return "ajoutAmi";

	}
	
		public String delete(){
		
		/* On supprime l'amiBean  */
		AmiBean ami = new AmiBean();
		ami.setId_eleve_ajout(this.id_eleve_courant);
		ami.setId_eleve_courant(this.id_eleve_ajout);
		
		amiBusinessCourante.Delete(ami);
		amiBusinessCourante.Delete(this);
		
		return "deleteAmi";

	}

}
